package logic;

import java.util.List;

/**
 * 
 * This is a patch of grass
 * @author Vossen en Konijnen group 2
 *
 */
public class Grass extends Plant
{
    // Characteristics shared by all patches of grass (static fields).

    // The age at which the grass start growing.
    private static int GROWING_AGE = 5;
    // The max age of the grass.
    private static int MAX_AGE = 80;
    // The likelihood of grass reproducing.
    private static double GROWING_PROBABILITY = 0.03;
    // The maximum number new patches per reproduction
    private static int MAX_LITTER_SIZE = 5;

    


    /**
     * Create a new patch of grass. A patch of grass may be created with age
     * zero (a new born) or with a random age.
     * 
     * @param randomAge If true, the patch of grass will have a random age.
     * @param field The field currently occupied.
     * @param location The location within the field.
     */
    public Grass(boolean randomAge, Field field, Location location)
    {
        super(field, location);
        if(randomAge){
        	setAge();
        	age = getAge();
        }
    }
    
    /**
     * This is what the patch of grass does most of the time - it just sits there.
     *  Sometimes it will breed or die of old age.
     * @param newGrass A list to add newly born rabbits.
     */
    public void act(List<Actor> newGrass)
    {
    	incrementAge();
        if(isAlive()) {
            growPlant(newGrass, getClass().getName());            
        }
    }

    /**
     * Returns the breeding age of this patch of grass
     * @return BREEDING_AGE of this patch of grass
     */
    public int getGrowingAge()
    {
    	return GROWING_AGE;
    }
    
    /**
     * Returns the maximum age of this patch of grass
     * @return MAX_AGE of this patch of grass
     */
    public int getMaxAge()
    {
    	return MAX_AGE;
    }
    
    /**
     * Returns the likelihood of this patch of grass to reproduce
     * @return BREEDING_PROBABILITY of this patch of grass
     */
    public double getGrowingProbability()
    {	
    	return GROWING_PROBABILITY;
    }
    
    /**
     * Returns the maximum number of births of this patch of grass
     * @return MAX_LITTER_SIZE of this patch of grass
     */
    public int getMaxLitterSize()
    {
    	return MAX_LITTER_SIZE;
    }
    

    
	@Override
	protected Plant newPlant(Field field, Location location) {
		Plant grass = new Grass(false, field, location);
		return grass;
	}   
	
	/**
	 * Sum's up the characteristics of the patch of grass.
	 * @return String
	 */
	public static String getStatic()
	{
		return 
		"Growing age: "+ GROWING_AGE + 
		", Max age: " + MAX_AGE + 
		", Growing probability: " + GROWING_PROBABILITY +
		", Max amount of new seeds: " + MAX_LITTER_SIZE;
	}
	
	/**
	 * sets the characteristics of the patch of grass.
	 * @param GAge
	 * @param MAge
	 * @param GProbability
	 * @param LitterSize
	 */
	public static void setStatic(int GAge, int MAge, double GProbability, int LitterSize)
	{
		GROWING_AGE = GAge;
		MAX_AGE = MAge;
		GROWING_PROBABILITY = GProbability;  
		MAX_LITTER_SIZE = LitterSize;
	}
}


